package com.hb.core.pojo.project.file.mapper;

import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hb.core.pojo.project.file.dto.BidBuyRecordDTO;
import com.hb.core.pojo.project.file.entity.BidBuyRecord;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 供应商购标记录表 Mapper 接口
 * </p>
 *
 * @author zhaojk
 * @since 2021-09-16
 */
public interface BidBuyRecordMapper extends BaseMapper<BidBuyRecord> {
    /**
     * 查询指定标段的标书售卖记录
     *
     * @param sectionId
     * @return
     */
    Page<BidBuyRecordDTO> saleRecord(@Param("page") Page page, @Param("sectionId") Long sectionId);

    /**
     * 查询指定标段的招标文件售卖信息
     *
     * @param sectionId
     * @return
     */
    @Select("select n.document_sale_end_time as documentSaleEndTime," +
            "tbs.price_per_package as pricePerPackage " +
            "from trade_notice_bid_section nbs " +
            "left join trade_notice n on nbs.notice_id=n.id " +
            "left join trade_bid_section tbs on tbs.id=nbs.section_id " +
            "where nbs.section_id=#{sectionId} " +
            "order by nbs.create_time desc limit 1")
    JSONObject sectionSaleInfo(Long sectionId);
}
